<template>
	<div class="dianpu-box">
		<div class="seachtop">
			<i><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shouye/logo_1.png" alt="" @click="zhuye()" /></i>
			<div class="seachbox"  @click="seachStuta==true&&seachbtn()" :class="{'divboxtran':!seachshow}">
				<div>
					<i class="searchicon"><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shouye/icon_search@2x.png" :class="{'imgtrans':!seachshow}"/></i>
					<span class="search-tishi" v-show="seachshow">请输入关键词</span>
					<form action="javascript:;" method="post" v-show="seachinputshow" class="seachfrom">
						<input type="search" id="seach" v-model="seachvalue" @keyup.enter="seachsend" placeholder="请输入关键词"/>
					</form>
				</div>
			</div>
			<span class="qxsousuo" @click="seachremove" v-show="seachrmshow">取消</span>
		</div>
		<div class="dianpu-xinxi">
			<router-link :to="{path:'/business/dianpuxq',query:{'store':store_id}}">
				<span class="dianpu-logo">
					<img :src="'http://www.ntyouxuan.com/'+dianpuxinxi.store_logo"/>
				</span>
				<div class="dianpu-text">
					<h3 v-text="dianpuxinxi.store_name">两玩家旗舰店</h3>
					<span v-text="'描述相符：'+msfen"></span>
					<span v-text="'服务态度：'+fwfen">4.5</span>
					<span v-text="'发货速度：'+fhfen">4.5</span>
				</div>
			</router-link>
		</div>
		<div class="dianpu-list">
			<h3><i><img src="../../img-dianpu/allorder@3x.png"/></i>全部商品</h3>
			<ul>
				<li class="dianpu-item" v-for="item in orderlist">
					<router-link :to="{name:'shopXQ',params:{id:item.goods_id}}">
						<img :src="'http://www.ntyouxuan.com/'+item.default_image"/>
						<h4 v-text="item.goods_name">良万家即食罐头蛤蜊肉肉 花蛤花蛤花蛤</h4>
						<span v-text="'￥'+item.price"></span>
					</router-link>
				</li>
			</ul>
		</div>
		<div class="dianpu-footer" v-if="kfshow==0" @click="ltskf">
			<i><img src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/newwap/shangpin/kefu.png"/></i>
			<span>在线客服</span>
		</div>
		<seachrm v-if="seachrmshow" @seachitems="seachsendtow"></seachrm>
	</div>
</template>

<script>
	import shopindCss from "@/css/bussshopindex.css"
	import seachrm from '@/components/seachview/seachmodel'
	export default{
		data(){
			return{
				user:0,
				store_id:0,
				page:1,
				scrollstatu:true,
				pagenum:0,
				orderlist:[],
				dianpuxinxi:'',
				msfen:5,
				fwfen:5,
				fhfen:5,
				seachvalue:'',
				seachStuta:true,
				seachshow:true,
				seachinputshow:false,
				keyword:'',
				seachrmshow:false,
				kfshow:0
			}
		},
		components:{seachrm},
		created:function(){
			this.user=localStorage.getItem("nt_user");
			this.store_id=this.$route.query.store;
			this.shopajax();
		},
		methods:{
			zhuye: function(){
				window.location.href='http://www.ntyouxuan.com/newnt/#/';
			},
			ltskf:function(){
				this.$router.push({path:'/informationshi',query:{'store_id':this.store_id}});
			},
			seachsend:function(){
				this.page=1;
				this.keyword=this.seachvalue;
				this.cate_id='';
				this.orderlist=[];
				this.shopajax();
				this.seachremove();
			},
			seachsendtow:function(data){
				this.page=1;
				this.keyword=data;
				this.cate_id='';
				this.orderlist=[];
				this.shopajax();
				this.seachremove();
			},
			seachbtn:function(){
				this.seachshow=false;
				var self=this;
				setTimeout(function () {
					self.seachinputshow=true;
					self.seachrmshow=true;
				},200)
				setTimeout(function () {
                	document.getElementById('seach').focus()
            	}, 300)
			},
			seachremove:function(){
				this.seachshow=true;
				this.seachinputshow=false;
				this.seachrmshow=false;
			},
			shopajax:function(){
				var self=this;
				$.ajax({
					type:"get",
					url:furl+"index.php?app=ajax_buyer_order&act=store_list",
					data:{'store_id':self.store_id,'page':self.page,'keyword':self.keyword},
					dataType:'json',
					success:function(res){
						self.orderlist=self.orderlist.concat(res.retval.goods_list);
						self.pagenum=res.retval.page.page_count;
						self.scrollstatu=true;
					}
				});
			},
			scrollajax:function(){
				if(this.scrollstatu){
					if(this.page+1<=this.pagenum){
						console.log(this.page+1<=this.pagenum);
						var dSH=$(document).scrollTop()
						var dH=$(document).height()
						var wH=$(window).height()
						if((dSH+wH)/dH>0.8){
							this.scrollstatu=false;
							this.page=this.page+1;
							this.shopajax();
						}
					}	
				}
			}
		},
		mounted:function(){
			var self=this;
			window.addEventListener("scroll",self.scrollajax);
			$.ajax({
				type:"get",
				url:furl+"index.php?app=ajax_buyer_order&act=store_detail",
				data:{'store_id':self.store_id,'token':self.user},
				dataType:'json',
				success:function(res){
					if(res.done){
						self.kfshow=res.retval.member_status;
						self.dianpuxinxi=res.retval.store;
						self.msfen=res.retval.evaluation.evaluation_desc;
						self.fwfen=res.retval.evaluation.evaluation_service;
						self.fhfen=res.retval.evaluation.evaluation_speed;
					}
				}
			});
		},
		destroyed:function () {
		    this.scrollstatu = false;
		}
	}
</script>

<style>

</style>